home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************
- * TEXTRA AREXX script -- Mike Haas, 1991, All Rights Reserved. *
- * Freely distributable ONLY as a component of the TEXTRA package. *
- * This banner may not be removed or altered (improvements to the *
- * actual program welcome). Please document and send to me. *
- * !!! PLACE THIS FILE IN YOUR REXX: DIRECTORY !!! *
- *******************************************************************/
-
- /* SCOOTTEST <num>
- *
- * SCOOTTEST reports if the lines in a selection would be moved to the left
- * less than <num> by SCOOT when <num> is negative. If some lines are moved
- * less than others, then a SCOOT to the right won't restore the lines to
- * orginal format. To see what this means, try "SCOOT -8", followed by
- * "SCOOT 8" on these comment lines. The askerisks will be smashed against
- * the left margin, then misshapen.
- *
- * <num> should match the value used with SCOOT. Some examples:
- *
- * scoottest -8
- * scoottest -4
- * scoottest -
- *
- * SCOOTing an entire 997-line C source file takes about 125 seconds.
- * SCOOTTEST will check the same file in 29 seconds (Amiga 3000/25).
- */
-
- /* Converted from SCOOT.TEXTRA by Ron Charlton */
- /* 00001 mdh 10-nov-92 Added ability to cancel script */
- /* 00002 mdh 20-nov-92 check version (cause of 'CheckCancel') */
-
- OPTIONS results
-
- rex = 0; result = "NOTSUPPORTED" /*00002*/
- textraversion
- parse var result maj min rex
- if (result == "NOTSUPPORTED") | (rex < 3) then do
- notify "Textra V1.13 or later required for this script."
- exit
- end
-
-
- tabchar = d2c(9)
-
-
- parse upper arg num /* get the argument */
-
- if (num == "") then
- do
- notify "Scoot: You must provide a negative number for <num>."
- exit
- end
-
- else if (num == "-") then
- do
- prefs TabWidth read
- num = -result /* use tab width from prefs */
- end
-
- get select position /* get the select boundary, if any */
-
- if (result == "NO SELECT") then /* is nothing selected? */
-
- do
- get cursor position /* nothing selected, get cursor pos */
- parse var result cursx ' ' cursy
- LinesSelected = 0 /* means 'just cursor' */
-
- end
-
- else
-
- do
- /* yes, there is a selection, get it's boundaries */
- parse var result startx ' ' starty ' ' endx ' ' endy
- LinesSelected = (endy - starty)
-
- /* if only the 'eol' of the previous line is selected
- (nothing on this line is actually included, i.e. x==0),
- then don't include it.
- */
- if (endx > 0) then LinesSelected = LinesSelected + 1
-
- end
-
- if (LinesSelected == 0) then
-
- do
- currline = cursy
- gotoxy 0 cursy
- call scoottest
- if (num > 0) then
- gotoxy cursx+num cursy
- else
- do
- if (firstcharpos == 0) then
- gotoxy cursx cursy
- else
- gotoxy max(cursx+num,0) cursy
- end
- end
-
- else
-
- do
- currline = starty; numLeft = LinesSelected
- do while (numLeft > 0)
- do
- CheckCancel; if (result == CANCEL) then exit /*00001*/
- gotoxy 0 currline
- call scoottest
- currline = currline + 1
- numLeft = numLeft - 1
- end
- end
- gotoxy 0 starty
- selectto 0 starty+LinesSelected
- end
-
- exit
-
-
- scoottest:
-
- get cursor char
- if (result == "-1") then
- /* empty line */
- return
- cursorchar = result
-
- if (cursorchar == ' ' | cursorchar == tabchar) then
- do
- hopto next char
- if (result == "NOT FOUND") then
- /* at end of file */
- return
- end
-
- get cursor position
- if (result == "SELECT") then
- /* cannot (?) happen */
- return
-
- parse var result firstcharpos ' ' cursoryscoot
- if (cursoryscoot ~= currline) then
- /* nothing on currline */
- return
-
- if (num < 0 & abs(num) > firstcharpos) then
- do
- if (LinesSelected > 0) then
- do
- ask "Line " || currline+1 || " cannot move left far enough. Continue test?"
- if (result == "NO") then numLeft = 0
- end
- else
- notify "Line " || currline+1 || " cannot move left far enough."
- end
-
- return
-
- Debug: procedure
- parse arg theString
- get select position /* get the select boundary, if any */
- if (result == "NO SELECT") then /* is nothing selected? */
- do
- get cursor position /* nothing selected, get cursor pos */
- parse var result cursxdbg ' ' cursydbg
- WasSelected = 0 /* means 'just cursor' */
- end
- else
- do
- /* yes, there is a selection, get it's boundaries */
- parse var result cursxdbg ' ' cursydbg ' ' endxdbg ' ' endydbg
- WasSelected = 1
- end
- lastline
- text theString
- gotoxy cursxdbg cursydbg
- if (WasSelected == 1) then selectto endxdbg endydbg
- return
-